const db = uniCloud.database()
exports.main = async (event, context) => {
  try {
    const res = await db.collection('topics')
      .where({
        type: 'review' // 精确匹配type字段为review的文档
      })
      .orderBy('create_time', 'desc') // 按创建时间倒序
      .get()
      
    return {
      code: 200,
      message: '获取成功',
      data: res.data
    }
  } catch (e) {
    console.error('云函数错误：', e)
    return {
      code: 500,
      message: '服务端错误',
      data: []
    }
  }
}